package 一维数组.习题;
//求平均值
public class text_2 {
    public static void main(String[] args) {
        double[] array = {1,2,3,4,5};
        double num = avg(array);
        System.out.println(num);
    }
    public static double avg(double[] array){
        double num = 0;
        for (int i = 0; i < array.length; i++) {
            num += array[i];
        }
        return num/array.length;
    }
}
